package org.aaron.demos.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class SqliteDatabaseHelper extends SQLiteOpenHelper {

	private static final int VERSION = 1;

	public SqliteDatabaseHelper(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	public SqliteDatabaseHelper(Context context, String name) {
		this(context, name, VERSION);
	}

	public SqliteDatabaseHelper(Context context, String name, int version) {
		this(context, name, null, version);
	}

	// 创建数据库表结构
	@Override
	public void onCreate(SQLiteDatabase db) {
		System.out.println("onCreate database.");
		db.execSQL("create table users(_id int,name varchar(20))");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		System.out.println("onUpgrade database.");
	}

	public boolean deleteDatabase(Context context, String dbname) {
		return context.deleteDatabase(dbname);
	}
}
